# Comment/uncomment the following line to enable/disable debugging
DEBUG = y

ifeq ($(DEBUG),y)
  DEBFLAGS = -O -g -DMMRP_DEBUG     # "-O" is needed to expand inlines
else
  DEBFLAGS = -O2
endif

EXTRA_CFLAGS += $(DEBFLAGS) -I$(LDDINC)
EXTRA_CFLAGS += -I$(PWD)/include
EXTRA_CFLAGS += -I$(PWD)/../kmrp/include

TARGET = mmrp

ifneq ($(KERNELRELEASE),)

mmrp-objs := src/mmrp_main.o

obj-m	:= mmrp.o

else

KERNELDIR ?= /usr/src/linux
PWD       := $(shell pwd)

modules:
	$(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)

endif

install:
	install -d $(INSTALLDIR)
	install -c $(TARGET).ko $(INSTALLDIR)

clean:
	rm -rf src/*.o *.o src/*~ *~ core .depend .*.cmd src/*.ko *.ko *.mod.c .tmp_versions

depend .depend dep:
	$(CC) $(CFLAGS) -M *.c > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif
